repo: Bump mtime any time we write a ref
authorColin Walters <walters@verbum.org>
Thu, 14 May 2015 01:59:17 +0000 (21:59 -0400)
committerColin Walters <walters@verbum.org>
Thu, 14 May 2015 10:33:31 +0000 (06:33 -0400)
External daemons like rpm-ostree want push notification any time a
change is made by an external entity.  inotify provides notification,
but a problem is there's no easy way to monitor all of the refs.

In the past, there has been discussion of opt-in recursive timestamps:
https://lkml.org/lkml/2013/4/5/307

But in today's world, let's just bump the mtime on the repo itself, as
a central inotify point.

Closes: https://github.com/GNOME/ostree/pull/111
src/libostree/ostree-repo-private.h
src/libostree/ostree-repo-refs.c
src/libostree/ostree-repo.c
tests/basic-test.sh

index 7b02b12c97ef3346c67a88c63988b4710a0b44b5..5214bcac0d0191be0ebc76ec45e2591b83174144 100644 (file)
@@ -255,5 +255,9 @@ _ostree_repo_read_bare_fd (OstreeRepo           *self,
                            int                  *out_fd,
                            GCancellable        *cancellable,
                            GError             **error);
+
+gboolean
+_ostree_repo_update_mtime (OstreeRepo        *self,
+                           GError           **error);
                            
 G_END_DECLS
index bd0b760b58dce1c321e2edf7a35632942e93b124..970f51919fef8556456f4465329b08585166374b 100644 (file)
@@ -631,6 +631,9 @@ _ostree_repo_write_ref (OstreeRepo    *self,
         goto out;
     }
 
+  if (!_ostree_repo_update_mtime (self, error))
+    goto out;
+
   ret = TRUE;
  out:
   return ret;
index 2f211494853bc0626dfc50d73104142ba186bcee..baeb60be2e3086b6726b9554f340ff35fa6f2273 100644 (file)
@@ -620,6 +620,18 @@ ostree_repo_is_writable (OstreeRepo *self,
   return self->writable;
 }
 
+gboolean
+_ostree_repo_update_mtime (OstreeRepo        *self,
+                           GError           **error)
+{
+  if (futimens (self->repo_dir_fd, NULL) != 0)
+    {
+      glnx_set_prefix_error_from_errno (error, "%s", "futimens");
+      return FALSE;
+    }
+  return TRUE;
+}
+
 /**
  * ostree_repo_get_config:
  * @self:
index 3b57f66d77507a1bf4c5f8369c53d2991d4f66e5..2fea4e033c86851ea41fd502c93658a38e03d706 100755 (executable)
@@ -401,3 +401,16 @@ if test "$(id -u)" != "0"; then
     assert_file_has_content error-message "Permission denied"
     echo "ok unwritable repo was caught"
 fi
+
+cd ${test_tmpdir}
+rm -rf test2-checkout
+mkdir -p test2-checkout
+cd test2-checkout
+touch blah
+stat --printf="%Z\n" ${test_tmpdir}/repo > ${test_tmpdir}/timestamp-orig.txt
+$OSTREE commit -b test2 -s "Should bump the mtime"
+stat --printf="%Z\n" ${test_tmpdir}/repo > ${test_tmpdir}/timestamp-new.txt
+cd ..
+if ! cmp timestamp-{orig,new}.txt; then
+    assert_not_reached "failed to update mtime on repo"
+fi